var con = require('./BaseModel')();
exports.getArticleByClass = function(className,callback){
     var sql = "select * from base_article where class = '"+className+"'";
     con.query(sql,function(err, rows, fields) {
		   callback(rows);
	 });
}
exports.getArticleById = function(article_id,callback){
	var sql = "select * from base_article where article_id = '"+article_id+"'";
     con.query(sql,function(err, rows, fields) {
		   callback(rows);
	 });
}
exports.getArticleByClassLimit = function(where,callback){
	var page      = where.page?where.page:1;
	var className = where.className?where.className:'company';
	var num       =  where.num?where.num:16;
	var start =  num*(page-1); 
	var sql = "select * from base_article where class = '"+className+"' order by sort limit "+start+","+num;
     con.query(sql,function(err, rows, fields) {
		   callback(rows);
	 });
}
exports.getArticleCountByClass = function(className,callback){
	var sql = "select count(*) as count from base_article where class = '"+className+"' ";
     con.query(sql,function(err, rows, fields) {
     	console.log(rows);
		   callback(rows);
	 });
}